Autodesk.AutoCAD.DatabaseServices Namespace > Entity Class > Entity Methods > JoinEntities Method
Entity.JoinEntities Method   
Description

This wraps AcDbJoinEntityPE::joinEntities(), which when implemented for an Entity can be used to join supported entities together. Some implementations might require the entities be of the same type, while other implementations might convert the data from the other entities to match the type of the this entity.

Visual Basic
Public Function JoinEntities(
    otherEntities As Entity[]
) As IntegerCollection
C#
public IntegerCollection JoinEntities(
    Entity\[\] otherEntities
);
Parameters
Parameters 
Description 
Entity[] otherEntities 
The other entities to be joined to the primary entity. Note, some implementations might require all of these entities to be of the same type as the primary entity. 
Returns

An array of indices to the entities from the otherEntities array that were successfully joined.

Remarks

Line.JoinEntities requires the given entities to be other Line entities that are collinear. 

Arc.JoinEntities requires the given entities to be other Arc entities that lie on the same circle. 

Ellipse.JoinEntities requires the given entities to be other, unclosed Ellipse entities that lie on the same ellipse. 

Spline.JoinEntities requires the given entities to be other, unclosed curves (Line, Polyline, Polyline2d, Polyline3d, Arc, 

Ellipse, Spline, Helix) which share common start or end points. 

Polyline3d.JoinEntities requires the given entities to be other, unclosed curves (Line, Polyline, Polyline2d, Polyline3d, Arc, 

Ellipse, Spline, Helix) which share common start or end points. Some curves (Arc, Ellipse, Spline, Helix) will be approximated by linear segments of the Polyline3d using Spline.ToPolyline. Preconvert those curves if a different approximation is required. 

Polyline2d.JoinEntities requires the given entities to be other, unclosed Polyline2d or Polyline, Line, and/or Arc entities, which share common start or end points. Curve-fit and spline-fit polylines are not supported. 

Polyline.JoinEntities requires the given entities to be other, unclosed Polyline or Polyline2d, Line, and/or Arc entities, which share common start or end points. 

See the JOIN command for additional information about the behavior of the join operation.

Exceptions
Exceptions 
Description 
Autodesk.AutoCAD.Runtime.Exception for ErrorStatus {InvalidInput} or {NotApplicable} 
_nt_ 
Example

<![CDATA[Database db = Application.DocumentManager.MdiActiveDocument.Database; Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = db.TransactionManager; 

using (Transaction t = tm.StartTransaction()) { try { Line pLine = new Line(new Point3d(10, 10, 0), new Point3d(10, 10, 1)); Line pLine1 = new Line(new Point3d(10, 10, 2), new Point3d(10, 10, 3)); Line pLine2 = new Line(new Point3d(0, 0, 0), new Point3d(1, 1, 0)); Line pLine3 = new Line(new Point3d(1, 1, 0), new Point3d(2, 2, 0)); 

Entity[] otherEntities = new Entity[2]; otherEntities[0] = pLine1; otherEntities[1] = pLine2; 

// join the other entities Autodesk.AutoCAD.Geometry.IntegerCollection joinedEntities = pLine.JoinEntities(otherEntities); if (joinedEntities.Count > 0) Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("nSome or all entities joined!"); } catch (Autodesk.AutoCAD.Runtime.Exception e) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("nJoin error: "); Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(e.ErrorStatus.ToString()); } t.Commit(); }]]>

Links
   Comments?